<?php namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * App\Facilitator
 *
 * @property integer $id
 * @property integer $user_id
 * @property string $nickname
 * @property string $realname
 * @property string $province
 * @property string $city
 * @property string $area
 * @property string $invite_num
 * @property string $telephone
 * @property string $qq
 * @property string $email
 * @property integer $img_photo_id
 * @property string $deleted_at
 * @property \Carbon\Carbon $created_at
 * @property \Carbon\Carbon $updated_at
 * @property-read \App\User $user
 * @method static \Illuminate\Database\Query\Builder|\App\Facilitator whereId($value)
 * @method static \Illuminate\Database\Query\Builder|\App\Facilitator whereUserId($value)
 * @method static \Illuminate\Database\Query\Builder|\App\Facilitator whereNickname($value)
 * @method static \Illuminate\Database\Query\Builder|\App\Facilitator whereRealname($value)
 * @method static \Illuminate\Database\Query\Builder|\App\Facilitator whereProvince($value)
 * @method static \Illuminate\Database\Query\Builder|\App\Facilitator whereCity($value)
 * @method static \Illuminate\Database\Query\Builder|\App\Facilitator whereArea($value)
 * @method static \Illuminate\Database\Query\Builder|\App\Facilitator whereInviteNum($value)
 * @method static \Illuminate\Database\Query\Builder|\App\Facilitator whereTelephone($value)
 * @method static \Illuminate\Database\Query\Builder|\App\Facilitator whereQq($value)
 * @method static \Illuminate\Database\Query\Builder|\App\Facilitator whereEmail($value)
 * @method static \Illuminate\Database\Query\Builder|\App\Facilitator whereImgPhotoId($value)
 * @method static \Illuminate\Database\Query\Builder|\App\Facilitator whereDeletedAt($value)
 * @method static \Illuminate\Database\Query\Builder|\App\Facilitator whereCreatedAt($value)
 * @method static \Illuminate\Database\Query\Builder|\App\Facilitator whereUpdatedAt($value)
 * @property-read \App\Images $photo
 * @property-read \App\Org $org
 * @property string $card_num
 * @property integer $img_cardf_id
 * @property integer $img_cardb_id
 * @method static \Illuminate\Database\Query\Builder|\App\Facilitator whereCardNum($value)
 * @method static \Illuminate\Database\Query\Builder|\App\Facilitator whereImgCardfId($value)
 * @method static \Illuminate\Database\Query\Builder|\App\Facilitator whereImgCardbId($value)
 * @property-read \App\Images $cardf
 * @property-read \App\Images $cardb
 * @property integer $state
 * @method static \Illuminate\Database\Query\Builder|\App\Facilitator whereState($value)
 * @property-read \App\Facilitator $followParent
 * @property-read \Illuminate\Database\Eloquent\Collection|\App\Facilitator[] $followChild
 * @property-read \Illuminate\Database\Eloquent\Collection|\App\Orders[] $orders
 * @property integer $t_state
 * @method static \Illuminate\Database\Query\Builder|\App\Facilitator whereTState($value)
 */
class Facilitator extends Model
{
    protected $table = 'facilitator';
    use SoftDeletes;

    public function user(){
        return $this->belongsTo('App\User','user_id');
    }

    /** 关联用户头像 */
    public function photo(){
        return $this->belongsTo('App\Images','img_photo_id');
    }

    public function cardf(){
        return $this->belongsTo('App\Images','img_cardf_id');
    }

    public function cardb(){
        return $this->belongsTo('App\Images','img_cardb_id');
    }

    public function org(){
        return $this->hasOne('App\Org','fac_id');
    }

    public function followParent(){
        return $this->belongsToMany('App\Facilitator','pusers','fid','pid');
    }

    public function followChild(){
        return $this->belongsToMany('App\Facilitator','pusers','pid','fid');
    }

    public function orders(){
        return $this->hasMany('App\Orders','fac_id');
    }

}